package com.cb.domain.dao.system.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.cb.core.dao.hibernate.GenericDAOHibernate;
import com.cb.core.webapp.paging.PagingBean;
import com.cb.domain.dao.system.AppResourceDAO;
import com.cb.domain.model.system.AppResource;
@Repository
public class AppResourceDAOImpl extends GenericDAOHibernate<AppResource, Long> implements AppResourceDAO {
	public AppResourceDAOImpl() {
		super(AppResource.class);
	}
	
	/**
	 * {@inheritDoc}
	 */
	public List<AppResource> getByVo(AppResource vo, PagingBean pb) {
		List<Object>paramList=new ArrayList<Object>();
		String hql="from AppResource vo where 1=1";
		
		/**TODO 添加自己的需要加入的查询条件
		if(StringUtils.isNotEmpty(vo.getUsername())){
			hql+=" and vo.username like ?";
			paramList.add("%"+vo.getUsername()+"%");
		}**/
		
		List <AppResource>list=this.find(hql, paramList.toArray(), pb);
		return list;
	}
	
	/**
	 * get by resourceName
	 * @param resourceName
	 * @return
	 */
	public AppResource getByResourceName(String resourceName){
		String hql="from AppResource vo where vo.resourceName=?";
		return (AppResource)findUnique(hql,new Object[]{resourceName});
	}
	
	public List getByParentId(Long parentId){
		String hql="from AppResource vo where vo.parentId=?";
		return find(hql, new Object[]{parentId});
	}
}

